package com.pre;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class Filter2 implements Filter {
	public Filter2() {
		  System.out.println("实例化过滤器2");
		}

	
    public void destroy() {
        System.out.println("Stopping filter2");
    }

    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
    	
        System.out.println("调用过滤器2: " + request);

        chain.doFilter(request, response);
    }

    public void init(FilterConfig filterConfig) throws ServletException {
    	 System.out.println("初始化过滤器2");
//        Enumeration<String> enums = filterConfig.getInitParameterNames();
//
//        while (enums.hasMoreElements()) {
//            String param = (String) enums.nextElement();
//            System.out.println(param + ":" + filterConfig.getInitParameter(param));
//        }
    }

}